package com.xbongbong.saas.model;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.IModel;
import com.xbongbong.saas.domain.entity.PaymentBalanceUserEntity;
import com.xbongbong.saas.domain.entity.UserTeamEntity;
import org.elasticsearch.action.support.WriteRequest;

import java.util.List;
import java.util.Map;

/**
 * @author 梁鲁江
 * @version v1.0
 * @date 2019/11/7 19:59
 * @since v1.0
 */
public interface PaymentBalanceUserModel extends IModel<PaymentBalanceUserEntity> {
    /**
     * 保存实体
     *
     * @param paymentBalanceUserEntity 团队实体
     * @return java.lang.Integer
     * @throws XbbException 数据库异常
     * @date 2019/2/14 16:42
     */
    Integer save(PaymentBalanceUserEntity paymentBalanceUserEntity) throws XbbException;

    /**
     * 获取单个实体
     *
     * @param key    id主键
     * @param corpid 公司id
     * @return com.xbongbong.saas.domain.entity.PaymentBalanceUserEntity
     * @author feng.zheng
     * @date 2019/2/14 16:43
     */
    PaymentBalanceUserEntity getByKey(Long key, String corpid);

    /**
     * 批量删除
     *
     * @param parentIdIn 父id
     * @param corpid                公司id
     * @return 是否成功
     * @throws XbbException 异常
     */
    Integer deleteBatchByParentId(List<Long>  parentIdIn, String corpid) throws XbbException;
    /**
     * 批量删除的恢复
     *
     * @param parentIdIn 父id
     * @param corpid                公司id
     * @return 是否成功
     * @throws XbbException 异常
     */
    Integer deleteBatchRollbackByParentId(List<Long> parentIdIn, String corpid) throws XbbException;
    /**
     * 根据联系人id删掉该联系人的协同团队
     *
     * @param customerId  关联客户id
     * @param contactId  联系人id
     * @param corpid     公司id
     * @return 是否成功
     * @throws XbbException 异常
     */
    Integer deleteBatchByCustomerAndContact(Long customerId, Long contactId, String corpid) throws XbbException;

    /**
     * 批量解散团队依据客户id
     * @param corpid
     * @param customerIdIn
     */
    void disbandedTeamByCustomerId(String corpid, List<Long> customerIdIn) throws XbbException;
    /**
     * 获取符合查询条件的记录
     *
     * @param param 查询条件
     * @return 符合查询条件的记录
     */
    @Override
    List<PaymentBalanceUserEntity> findEntitys(Map<String, Object> param);

    /**
     * 根据联系人id批量删除
     * @param contactIdIn 联系人id
     * @param corpid 公司id
     * @return
     */
    Integer deleteBatchByContactIdIn(List<Long> contactIdIn, String corpid) throws XbbException;

    /**
     * 根据客户id和userId删除联系人团队
     *
     * @param corpid
     * @param customerId
     * @param userId
     * @author feng.zheng
     * @return java.lang.Integer
     * @date 2019/3/10 15:13
     */
    Integer deleteByUserIdAndCustomerId(String corpid, Long customerId, String userId) throws XbbException;

    List<UserTeamEntity> findBaseEntitys(Map<String,Object> map);

    void insertBatch(List<PaymentBalanceUserEntity> paymentBalanceUserEntityList ) throws XbbException;

    void insertBatch(List<PaymentBalanceUserEntity> paymentBalanceUserEntityList, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    void batchUpdateByUserIdIn(String corpid, List<Long> idIn, List<UserTeamEntity> teamEntityList, Integer isMain, Integer del) throws XbbException;

    void batchUpdateByUserIdIn(String corpid, List<Long> idIn, List<UserTeamEntity> teamEntityList, Integer isMain, Integer del, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    void batchUpdateByUserIds(String corpid, List<Long> idIn, List<PaymentBalanceUserEntity> teamEntityList, Integer isMain, Integer del) throws XbbException;

    void deleteBatchUser(List<PaymentBalanceUserEntity> paymentBalanceUserEntityList, String corpid) throws XbbException;

    /**
     * 获取该客户的所有团队
     * @param corpid
     * @param customerId
     * @return java.util.List<com.xbongbong.saas.domain.entity.PaymentBalanceUserEntity>
     * @date 2019-09-23
     */
    List<PaymentBalanceUserEntity> getListByCustomerId(String corpid, Long customerId);

    void batchUpdateCoAndPerByUserIdIn(String corpid, List<Long> dataIdIn, List<UserTeamEntity> teamEntityList, Integer isMain, boolean needThrow) throws XbbException;

    void batchUpdateCoAndPerByUserIdIn(String corpid, List<Long> dataIdIn, List<UserTeamEntity> teamEntityList, Integer isMain, boolean needThrow, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    /**
     * 获取所有公司信息
     *
     * @return
     */
    List<String> getAllCorpList();
}
